

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>crushdiff – ceph crush 图测试工具 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="crushtool – CRUSH 图操作工具" href="../crushtool/" />
    <link rel="prev" title="ceph-syn – ceph 的人造负载生成器" href="../ceph-syn/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../../rados/">Ceph 存储集群</a> &raquo;</li>
        
          <li><a href="../../../rados/man/">对象存储手册页</a> &raquo;</li>
        
      <li>crushdiff – ceph crush 图测试工具</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../../_sources/man/8/crushdiff.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../">
          

          
            
            <img src="../../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../rados/">Ceph 存储集群</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../rados/configuration/">配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../rados/operations/">运维</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../../rados/man/">    手册页</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../ceph-volume/">ceph-volume – Ceph OSD 部署和检查工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-volume-systemd/">ceph-volume-systemd – systemd ceph-volume 辅助工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph/">ceph – Ceph 管理工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-authtool/">ceph-authtool – ceph 密钥环操作工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-clsinfo/">ceph-clsinfo – 查看类对象信息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-conf/">ceph-conf – ceph 配置文件工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-debugpack/">ceph-debugpack – ceph 调试信息打包工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-dencoder/">ceph-dencoder – ceph 编码器/解码器工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-mon/">ceph-mon – ceph 监视器守护进程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-osd/">ceph-osd – ceph 对象存储守护进程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-kvstore-tool/">ceph-kvstore-tool – ceph 的 kvstore 操作工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-run/">ceph-run – 发生核心转储后重启守护进程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-syn/">ceph-syn – ceph 的人造负载生成器</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">crushdiff – ceph crush 图测试工具</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">提纲</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">描述</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">选项</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">命令</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">实例</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">使用范围</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">参考</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../crushtool/">crushtool – CRUSH 图操作工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../librados-config/">librados-config – 显示关于 librados 的信息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../monmaptool/">monmaptool – ceph 监视器运行图操作工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../osdmaptool/">osdmaptool – ceph osd 运行图操作工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rados/">rados – rados 对象存储工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-post-file/">ceph-post-file – 把文件上传给 ceph 开发者</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../rados/troubleshooting/">故障排除</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../rados/api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="crushdiff-ceph-crush">
<span id="crushdiff"></span><h1>crushdiff – ceph crush 图测试工具<a class="headerlink" href="#crushdiff-ceph-crush" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id1">
<h2>提纲<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<div class="line-block">
<div class="line"><strong>crushdiff</strong> [ –osdmap <em>osdmap</em> ] [ –pg-dump <em>pg-dump</em> ]
[ –compiled ] [ –verbose ] <em>command</em> <em>crushmap</em></div>
</div>
</div>
<div class="section" id="id2">
<h2>描述<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p><strong>crushdiff</strong> 是让我们测试 crushmap 更改
（ PG 数、挪动的对象和字节数）效果的工具。
这是 <a class="reference internal" href="../osdmaptool/"><span class="doc">osdmaptool</span></a>(8) 的一个包装，
用它的 <strong>–test-map-pgs-dump</strong> 选项获取更改过的 PG 列表。
另外，它用 pg 统计功能计算要挪动的对象和字节数。</p>
<p>默认情况下， <strong>crushdiff</strong> 会使用集群的当前 osdmap 和 pg 统计信息，
因此需要集群的访问权限。虽然你也可以用 <strong>–osdmap</strong> 和 <strong>–pg-dump</strong> 选项来测试前面获取到的数据。</p>
</div>
<div class="section" id="id3">
<h2>选项<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-crushdiff-compiled">
<code class="sig-name descname"><span class="pre">--compiled</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-crushdiff-compiled" title="Permalink to this definition">¶</a></dt>
<dd><p>用来指示输入、输出的 crushmap 是编译过的。
如果没指定此选项，想要的、返回的 crushmap 就是
txt （反编译过的）格式的。</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-crushdiff-pg-dump">
<code class="sig-name descname"><span class="pre">--pg-dump</span></code><code class="sig-prename descclassname"> <span class="pre">&lt;pg-dump&gt;</span></code><a class="headerlink" href="#cmdoption-crushdiff-pg-dump" title="Permalink to this definition">¶</a></dt>
<dd><p><strong>ceph pg dump</strong> 的 JSON 格式输出。如果你没指定，
<strong>crushdiff</strong> 会尝试自己调用命令获取数据。</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-crushdiff-osdmap">
<code class="sig-name descname"><span class="pre">--osdmap</span></code><code class="sig-prename descclassname"> <span class="pre">&lt;osdmap&gt;</span></code><a class="headerlink" href="#cmdoption-crushdiff-osdmap" title="Permalink to this definition">¶</a></dt>
<dd><p>就是集群的 osdmap ，通过 <strong>ceph osd getmap</strong> 命令获取到的。
如果没指定此选项， <strong>crushdiff</strong> 会尝试自己调用命令获取数据。</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-crushdiff-verbose">
<code class="sig-name descname"><span class="pre">--verbose</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-crushdiff-verbose" title="Permalink to this definition">¶</a></dt>
<dd><p>输出诊断信息。</p>
</dd></dl>

</div>
<div class="section" id="id4">
<h2>命令<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<dl class="simple">
<dt><strong class="command">compare</strong> <em>crushmap</em></dt><dd><p>比较 <em>crushmap</em> 文件里的和集群 osdmap 里的 crushmap 。
其输出将会展示期望的 pg 数、安装新 crushmap 后需要挪动的对象数和字节数。</p>
</dd>
<dt><strong class="command">export</strong> <em>crushmap</em></dt><dd><p>把集群 osdmap 里的 crushmap 导出到 <em>crushmap</em> 文件。</p>
</dd>
<dt><strong class="command">import</strong> <em>crushmap</em></dt><dd><p>把 <em>crushmap</em> 文件里的 crushmap 导入到集群的 osdmap 里。</p>
</dd>
</dl>
</div>
<div class="section" id="id5">
<h2>实例<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<p>获取当前的 crushmap:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">crushdiff</span> <span class="n">export</span> <span class="n">cm</span><span class="o">.</span><span class="n">txt</span>
</pre></div>
</div>
<p>编辑此图:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$EDITOR cm.txt
</pre></div>
</div>
<p>检查结果:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">crushdiff</span> <span class="n">compare</span> <span class="n">cm</span><span class="o">.</span><span class="n">txt</span>

<span class="mi">79</span><span class="o">/</span><span class="mi">416</span> <span class="p">(</span><span class="mf">18.99</span><span class="o">%</span><span class="p">)</span> <span class="n">pgs</span> <span class="n">affected</span>
<span class="mi">281</span><span class="o">/</span><span class="mi">1392</span> <span class="p">(</span><span class="mf">20.19</span><span class="o">%</span><span class="p">)</span> <span class="n">objects</span> <span class="n">affected</span>
<span class="mi">80</span><span class="o">/</span><span class="mi">1248</span> <span class="p">(</span><span class="mf">6.41</span><span class="o">%</span><span class="p">)</span> <span class="n">pg</span> <span class="n">shards</span> <span class="n">to</span> <span class="n">move</span>
<span class="mi">281</span><span class="o">/</span><span class="mi">4176</span> <span class="p">(</span><span class="mf">6.73</span><span class="o">%</span><span class="p">)</span> <span class="n">pg</span> <span class="nb">object</span> <span class="n">shards</span> <span class="n">to</span> <span class="n">move</span>
<span class="mf">730.52</span><span class="n">Mi</span><span class="o">/</span><span class="mf">10.55</span><span class="n">Gi</span> <span class="p">(</span><span class="mf">6.76</span><span class="o">%</span><span class="p">)</span> <span class="nb">bytes</span> <span class="n">to</span> <span class="n">move</span>
</pre></div>
</div>
<p>运行时如果加了 <strong>–verbose</strong> 选项，
输出内容里也会包含受影响 PG 的详细信息，如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mf">4.3</span>     <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
<span class="mf">4.</span><span class="n">b</span>     <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="mf">4.</span><span class="n">c</span>     <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
</pre></div>
</div>
<p>即，一个 PG 号、及其 osd 的新旧 active set 对比。</p>
<p>如果对结果满意就安装更新过的图：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">crushdiff</span> <span class="kn">import</span> <span class="nn">cm.txt</span>
</pre></div>
</div>
</div>
<div class="section" id="id6">
<h2>使用范围<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<p><strong>crushdiff</strong> 是 Ceph 的一部分，这是个伸缩力强、开源、
分布式的存储系统，更多信息参见 <a class="reference external" href="https://docs.ceph.com">https://docs.ceph.com</a> 。</p>
</div>
<div class="section" id="id7">
<h2>参考<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="../ceph/"><span class="doc">ceph</span></a>(8),
<a class="reference internal" href="../crushtool/"><span class="doc">crushtool</span></a>(8),
<a class="reference internal" href="../osdmaptool/"><span class="doc">osdmaptool</span></a>(8),</p>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../crushtool/" class="btn btn-neutral float-right" title="crushtool – CRUSH 图操作工具" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../ceph-syn/" class="btn btn-neutral float-left" title="ceph-syn – ceph 的人造负载生成器" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>